OpenBuildings GenerativeComponents Help

The DataImporter Node

A DataImporter represents a table of data that has been loaded from an external database.

Subsequently, that data can be used to populate the child members of another node (or set of nodes). For example, if a DataImporter contains a list of X, Y and Z coordinates, those values can be used to populate the child members of a Point node.

A DataImporter has three techniques, which differ depending on how you want to connect to the external database, and how the table of data should be loaded from that database.

The techniques are:

ByDatabase - technique

Generally, this technique is for loading data from a database that resides in a single file on your local computer; for example, an Access database.

The following properties define this technique.

DatabaseType: DatabaseType

The type of the database. One of the enumerated values Access, CommaSeparatedText, or SqlServerLocalDB.

(A CommaSeparatedText database is a plain text file in which the first line comprises a list of column names separated by commas, and each of the remaining lines comprises a list of values separated by commas.)

FilePath: string

The full path and file name of the database file. (Remember that you can enter this value by using the Expression Builder's file browser.)

SqlSelectCommand: string

A Transact-SQL SELECT command that will be used to load the DataImporter's internal data table from the database file.

Examples:

'SELECT * FROM myTable'
Load the entire contents of the database table, 'myTable'.

(In the case of a CommaSeparatedText database, the table name would be the name of the text file, including the '.txt' extension.)

 'SELECT X, Y, Z FROM myTable'
Load the specified columns ('X', 'Y' and 'Z') of the database table, 'myTable'.
'SELECT X AS Xtranslation, Y As Ytranslation, Z AS Ztranslation FROM myTable' 
Load the specified columns ('x', 'y' and 'z') of the database table, 'myTable'. Furthermore, within the DataImporter, treat those columns as if they're named 'Xtranslation', 'Ytranslation' and 'Ztranslation', respectively.

The SELECT command is powerful and flexible. Among other things, you can specify a conditional clause (WHERE), a sort sequence (ORDER BY), and a way to read data from multiple tables simultaneously (JOIN).

Note: The full formulation of a SELECT command is beyond the scope of this document. For more information, please consult documentation for Microsoft's Transact-SQL language.

ByTable - technique

Generally, this technique is for loading data from a simple text file, when the power of SQL is not needed. Currently, this technique supports only one file format, which is the native XML format of ADO.NET's DataSet class. Future versions of GC may support additional formats.
Note: You can load a comma-delimited text file with the ByDatabase technique, described above.

The following properties define this technique.

TableType: DataTableType

Currently, there is only one possible value, XmlWithSchema.

FilePath: string

The full path and file name of the text file.
Remember: You can enter this value by using the Expression Builder's file browser.

ColumnTypes: Type[] - optional

ColumnNames: string[] - optional

ColumnWidths: int[] - optional

This set of optional properties serves two purposes:
  1. If this is a new text file, for which no other schema information exists, these properties define the schema.
  2. If this is an existing text file, these properties provide an "override" of the schema information that's stored in the file.
For example, the columns in the file are named 'x', 'y' and 'z', but you want them to be named 'Xtranslation', 'Ytranslation' and 'Ztranslation' within the DataImporter.

If you don't specify any column information, the columns in the DataImporter are the same as those defined in the file.

ByConnection - technique

Generally, this technique is for connecting to a database that doesn't reside on your local computer, and/or uses a different file format than is supported by the other techniques. This technique provides the greatest degree of power and flexibility, but also requires the greatest level of expertise on your part.

The following properties define this technique.

ConnectionType: DataConnectionType

One of the enumerated values Odbc, OleDb, or SqlClient.

ConnectionString: string

A connection string that is valid to an ADO.NET data connection object of the specified connection type. The formulation of an ADO.NET connection string is beyond the scope of this document. For more information, please consult documentation for Microsoft's ADO.NET.

SqlSelectCommand: string

The Transact-SQL SELECT command that will be used to load the DataImporter.
Tip: For more information, please consult documentation for Microsoft's Transact-SQL language.